package com.mofang.powerdekorhelper.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.mofang.powerdekorhelper.R;
import com.mofang.powerdekorhelper.activity.activity.ActivityManagerAct;
import com.mofang.powerdekorhelper.base.recycleview.BaseRecycleViewAdapter;
import com.mofang.powerdekorhelper.base.recycleview.BaseViewHolder;
import com.mofang.powerdekorhelper.model.PastActivityList;

import java.util.List;

/**
 * Created by luofei on 2017/9/6 0006.
 * 说明：
 */

public class PastActivityAdapter extends BaseRecycleViewAdapter {

    public PastActivityAdapter(List<?> data, Context mContext, int layoutId) {
        super(data, mContext, layoutId);
    }

    @Override
    protected <T> void convert(BaseViewHolder holder, T bean, int position) {

        final PastActivityList.Data data = (PastActivityList.Data) bean;

        if (data.getName() != null) {
            holder.setText(R.id.activity_list_name, "活动名称：" + data.getName());
        }

        if (data.getCreate_time() != null && !data.getCreate_time().equals("")) {
            holder.setText(R.id.activity_list_time, "创建时间：" + data.getStart_time() + "——" + data.getEnd_time());
        }

        if (data.getImgurl() != null) {
            holder.setImage(R.id.activity_list_imv, data.getImgurl(), R.mipmap.list_defaut_bg);
        }

        holder.setOnclickListener(R.id.activity_list_detail_btn, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext.startActivity(new Intent(mContext, ActivityManagerAct.class)
                        .putExtra("ActivityId", data.getActivity_id())
                        .putExtra("ActivityCode", data.getActivity_code())
                        .putExtra("ActivityName", data.getName()));
            }
        });

        holder.itemView.setTag(data);

    }
}
